package com.qf.domain;

import java.util.List;

public class PageBen<T> {

    private  int pageName;
    private  int pageSize;
    private  int pageCount;
    private  long totalSize;
    private  List<T> data;
    //开始页码（固定）
    private int startPage;
    //结束页码（固定）
    private int endPage;



    public PageBen() {
    }

    public PageBen(int pageName, int pageSize, long totalSize, List<T> data) {
        this.pageName = pageName;
        this.pageSize = pageSize;
        this.totalSize = totalSize;
        this.data = data;
        pageCount= (int) (this.totalSize%this.pageSize==0?this.totalSize/this.pageSize:this.totalSize/this.pageSize+1);
        //开始页码
//        this.startPage=pageName;
        //结束页码
//        this.endPage=10;
        //开始页码和结束页码赋值
        //正常情况

        this.startPage=this.pageName-4;
        this.endPage=this.pageName+5;

        //当前页码小于5  固定 1-10
        if (this.pageName<5){
            this.startPage=1;
            this.endPage=10;
        }
        //当前页码是最后五页
        if (this.pageName+5>pageCount){
            this.startPage=this.pageCount-9;
            this.endPage=this.pageCount;
        }
        //总页数小于10
        if (pageCount<=10){
            this.startPage=1;
            this.endPage=this.pageCount;
        }

    }

    public int getPageName() {
        return pageName;
    }

    public void setPageName(int pageName) {
        this.pageName = pageName;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getPageCount() {
        return pageCount;
    }

    public void setPageCount(int pageCount) {
        this.pageCount = pageCount;
    }

    public long getTotalSize() {
        return totalSize;
    }

    public void setTotalSize(long totalSize) {
        this.totalSize = totalSize;
    }

    public List<T> getData() {
        return data;
    }

    public void setData(List<T> data) {
        this.data = data;
    }
    public int getStartPage() {
        return startPage;
    }

    public void setStartPage(int startPage) {
        this.startPage = startPage;
    }

    public int getEndPage() {
        return endPage;
    }

    public void setEndPage(int endPage) {
        this.endPage = endPage;
    }
    @Override
    public String toString() {
        return "pageBen{" +
                "pageName=" + pageName +
                ", pageSize=" + pageSize +
                ", pageCount=" + pageCount +
                ", totalSize=" + totalSize +
                ", data=" + data +
                '}';
    }
}
